<link rel="stylesheet" type="text/css" href="__TEMP__/{$style}/public/css/scroll.css">
<link rel="stylesheet" type="text/css" href="__TEMP__/{$style}/public/css/detail.css">
<link rel="stylesheet" type="text/css" href="__TEMP__/{$style}/public/css/components.css">
<script src="__TEMP__/{$style}/public/js/scroll.js" type="text/javascript"></script>
<script src="__TEMP__/{$style}/public/js/countdown.js" type="text/javascript"></script>
<style>
.address-select{
	width: 30%;
    float: left;
    border: 1px solid #e5e5e5;
	height: 20px;
    line-height: 20px;
    margin: 5px 15px;
    margin-left: 0;
}

</style>
<!-- 商品详情 -->
<div class="h50" style="height:45px;"></div>
<section id="banner">
	<div class="shop_slider shop_slider_auto" data-tag="module-slider" data-height="320px">
		<div class="inner" data-tag="slider-warp" >
			<ul class="pic_list" data-tag="slider-list">
			{foreach name = "goods_detail['img_list']" item = 'img_list' key='key' }
				<li style="width: 320px;">
					<div>
						<img alt="图片" class="pp_init_img" src="__ROOT__/{$img_list.pic_cover_big}" />
					</div>
				</li>
			{/foreach}
			</ul>
		</div>
		<div class="bar_wrap">
			<ul class="bar" data-tag="slider-page">
				<li class="cur"></li>
				<li></li>
				<li></li>
			</ul>
		</div>
	</div>
</section>
{if condition = "$goods_detail['promotion_info'] neq ''"}
<div class="goods-header js-goods-header goods-activity clearfix">
	<input type="hidden" id="end_time"  value="{$goods_detail['promotion_detail']['end_time']}"/>
	<div class="goods-price">
		<div class="current-price activity-price">
			<span>￥</span><i class="js-goods-price price">{$goods_detail.promotion_price}</i>
			<span class="price-title js-price-title ">限时折扣</span>
		</div>
		<em class="original-price">{$goods_detail.price}</em>
		<div class="font-size-12 overview-countdown js-activity-tips started " data-status="started">
			<div class="countdown-title">距结束仅剩</div>
			<div class="js-discount-time countdown" data-countdown="3542691">
			<span class="c-red js-day">00</span> 天 
			<span class="c-red js-hour">00</span> 时 
			<span class="c-red js-min">00</span> 分 
			<span class="c-red js-sec">00</span> 秒</div>
		</div>
	</div>
</div>
{/if}
<div class="buy_area">
	<div class="fn_wrap">
		<h1 class="title" id="itemName">{$goods_detail.goods_name}</h1>
	</div>
	<div class="price_wrap">
		<span class="tit" id="priceTitle"></span> 
		<span class="price" price="{$goods_detail.promotion_price}">
			<span style="font-size:14px;display: inline-block;vertical-align: middle;">￥</span>
			{if condition="$goods_detail.promotion_price < $goods_detail.member_price"}{$goods_detail.promotion_price}{else/}{$goods_detail.member_price}{/if}
			{if condition="$goods_detail.point_exchange_type==1 && $goods_detail.point_exchange>0"}
			<span style="font-size:16px;display: inline-block;vertical-align: middle;">+{$goods_detail.point_exchange}积分</span>
			{/if}
		</span>
		<span class="flag" id="priceDis" style="display: none"></span>
	</div>
	
	{if condition="$goods_detail.max_buy>0"}
	<hr class="with-margin-l" />
	<hr class="divider-line" />
	<div class="price_postage">
		<span class="price_postage_tit">
		<i style="color: #fff;font-size: 12px;padding: 3px;background: #f44;border-radius: 2px;">限购数量</i>&nbsp;{$goods_detail.max_buy}个</span>
	</div>
	{/if}
	<hr class="with-margin-l" />
	<div class="stock-detail" >
<!-- 			<span class="price_postage_tit">运费：{$goods_detail['shipping_fee_name']}</span> -->
	</div>
</div>
<hr class="with-margin-l" />
<hr class="divider-line" />
{if condition = "$goods_detail['mansong_name'] neq ''"}
<div class="price_postage">
	<span class="price_postage_tit js-reduced-send single"><i style="color: #fff;font-size: 12px;padding: 3px;background: #f44;border-radius: 2px;">满减</i>&nbsp;{$goods_detail['mansong_name']}</span>
</div>
<hr class="with-margin-l" />
<hr class="divider-line" />
{/if}

{if condition = "$goods_detail['give_point'] neq 0"}
<div class="price_postage">
	<span class="price_postage_tit"><i class="fa fa-database" style="color: #F44;margin-right: 5px;"></i>赠送积分<span style="color:#F44;padding:0;">{$goods_detail['give_point']}</span>分</span>
</div>
<hr class="with-margin-l" />
{/if}
	
	<div class="mod_tab_wrap">
		<div class="mod_tab" id="detailTab">
			<span onclick="showProperty(this,1)" class="cur">商品详情</span>
			<span onclick="showProperty(this,2)" >商品属性</span>
			<span onclick="showProperty(this,3)">商品评价</span>
		</div>
	</div>
	
	<!-- 商品详情 -->
	<div class="detail_info_wrap" id="p-detail">
		<div class="detail_list" id="content">{$goods_detail.description}</div>
	</div>
	<!-- 商品属性 -->
	<div class="detail_info_wrap p-attribute" id="p-attribute" style="display:none;" >
		{if condition = "count($goods_detail['goods_attribute_list']) gt 0"}
			<ul class="attribute-ul">
				{foreach $goods_detail["goods_attribute_list"] as $vo}
				<li>
					<em>{$vo.attr_value}：</em>
					<span id="goods_attr_" title="{$vo.attr_value_name}" class="goods-attr-value">{$vo.attr_value_name}</span>
				</li>
				{/foreach}
			</ul>
		{/if}
	</div>
	
	<!-- 商品评论 -->
	<div class="comment-type" id="productproperty" style="display:none;">
		<ul class="tab-nav">
			<li class="productproperty-list current" data-type="0" >全部<em>({$evaluates_count['evaluate_count']})</em></li>
			<li class="productproperty-list" data-type="4"  >图片 <em>({$evaluates_count['imgs_count']})</em></li>
			<li class="productproperty-list" data-type="1" >好评 <em>({$evaluates_count['praise_count']})</em></li>
			<li class="productproperty-list" data-type="2" >中评 <em>({$evaluates_count['center_count']})</em></li>
			<li class="productproperty-list" data-type="3" > 差评 <em>({$evaluates_count['bad_count']})</em></li>
		</ul>
		<!-- 评论展示 -->
		<div id="comment_content">
			<div class="comment-con"></div>
		</div>
	</div>
	
	{include file="wap/default/controlCopyRight"}
	<!-- 弹出框 -->
	<div class="success-tip-line" id="success_tip_line" style="display: none;">成功加入购物车！</div>
	<div class="mask" id="mask" style="display: none;"></div>
	<span id="addcart_way" style="display: none;"><i></i></span>
	<section class="s-buy" id="s_buy">
		<div class="popup"  id="popup" style="-webkit-border-radius:3px;-moz-border-radius:3px;-o-border-radius:3px;border-radius:3px;display: none"></div>
		<ul class="s-buy-ul">
			<li class="s-buy-pro">
				<span class="pro-img">
					<input type="hidden" id="default_img" value="{$goods_detail['img_list'][0]['pic_id']}" />
					<img src="__ROOT__/{$goods_detail['img_list'][0]['pic_cover_small']}" >
				</span>
				<div class="pro-info">
					<p class="name" >{$goods_detail.goods_name}</p>
					<p class="pro-price" id="price">
						￥{if condition="$goods_detail.promotion_price < $goods_detail.member_price"}{$goods_detail.promotion_price}{else/}{$goods_detail.member_price}{/if}
						{if condition="$goods_detail.point_exchange_type==1 && $goods_detail.point_exchange>0"}
						<span style="font-size:16px;display: inline-block;vertical-align: middle;">+{$goods_detail.point_exchange}积分</span>
						{/if}
					</p>
				</div>
				<i class="icon-close" id="icon_close"></i>
			</li>
		</ul>
		<hr class="with-margin-l" />
		<ul class="s-buy-ul specification" id="specification">
			{foreach name="goods_detail['spec_list']" item="spec" key="k"}
			<li class="s-buy-li" >
				<div class="left">{$spec.spec_name}：</div>
				<div class="right" name="specvals" >
				{foreach name="spec['value']" item="spec_value"}
					{if condition="$spec_value['spec_id'] eq $spec['spec_id']"}
						<button class="select" name="Span{$k}" id="{$spec_value.spec_id}:{$spec_value.spec_value_id}" onclick="change(this);">
						{$spec_value.spec_value_name}
						</button>
					{/if}
				{/foreach}
				</div>
			</li>
			<hr class="with-margin-l" />
			{/foreach}
			{foreach name="goods_detail['sku_list']" item="pro_skus" key="k"}
			<input type="hidden" id="goods_sku{$k}" value="{$pro_skus.attr_value_items}" stock="{$pro_skus.stock}" {if condition="$pro_skus.promote_price < $pro_skus.member_price" }price="{$pro_skus.promote_price}" {else/}price="{$pro_skus.member_price}"{/if} promotion_price="{$pro_skus.promote_price}" member_price="{$pro_skus.member_price}" skuid="{$pro_skus.sku_id}" skuname="{$pro_skus.sku_name}" class="sku-array">
			{/foreach}
			<input type="hidden" id="goods_sku_num" value="100">
			<li class="s-buy-li">
				<div class="left" style="float:left;">购买数量：</div>
				<div class="right">
					<span class="reduce quantity-minus-disabled">-</span>
					<input class="number" name="quantity" autocomplete="off" value="1" min="1" max="{$goods_detail.stock}" id="num" />
					<span class="add">+</span>
				</div>
				<span style="display: inline-block;margin-top:5px;color:#333;" id="Stock">剩余{$goods_detail.stock}件</span>
				{if condition ="$goods_detail['max_buy'] neq '0' AND $goods_detail['max_buy'] neq -1"}
				<span style="display: inline-block;margin-top:5px;color:#333;">限购{$goods_detail['max_buy']}件</span>
				{/if}
			</li>
		</ul>
		<ul class="s-buy-ul">
			<li class="s-buy-btn">
				<a class="btn" id="submit_ok" tag="buyBtn1">确定</a>
				<input id="hiddPDetailID" type="hidden" value="{$goods_detail.goods_id}"/>
				<input id="hiddSkuId" type="hidden" />
				<input id="hiddSkuName" type="hidden" />
				<input id="hiddSkuprice" type="hidden" />
				<input id="hiddStock" type="hidden" value="{$goods_detail.stock}"/>
				<input type="hidden" id="hidden_shop_name" value="{$goods_detail.shop_name}"/>
				<input type="hidden" id="hidden_shop_id" value="{$goods_detail.shop_id}"/>
				<input type="hidden" id="is_sale" value="{$goods_detail.state}" />
				<input type="hidden" id="goods_id" value="{$goods_detail.goods_id}" />
				<input type="hidden" id="code" value="{$goods_detail.code}" />
				<input type="hidden" id="max_buy" value="{$goods_detail.max_buy}" />
				<input type="hidden" id="hidden_current_num" value="{$num}" />
			</li>
		</ul>
	</section>
<script type="text/javascript">
$(function () {
	countDown();//计时器
	
	//分享
	$.ajax({
		type:"post",
		data : {"shop_id" : "{$shop_id}" , "flag" : "goods" , "goods_id" : "{$goods_id}"},
		url : "APP_MAIN/goods/getShareContents",
		success : function(data){
			{include file='wap/default/shareContents'/}
		}
	});
});

//商品评价
$(".comment-type li").click(function() {
	var type = $(this).data("type");
	var target = $(this);
	$(".comment-type").find("li").removeClass("current");
	$(".comment-type").find("i").removeClass("cur");
	$(target).addClass("current");
	$(target).children().addClass("cur");
	GetDataList();
})


function showProperty(sobj,type){
	$("#detailTab span").removeClass("cur");
	$(sobj).addClass("cur");
	if(type==1){
		$("#productproperty").hide();
		$("#p-detail").show(); 
		$("#p-attribute").hide();
	}else if(type == 2){
		$("#productproperty").hide();
		$("#p-detail").hide();
		$("#p-attribute").show();
	}else{
		$("#productproperty").show();
		$("#p-detail").hide(); 
		$("#p-attribute").hide();
		GetDataList();
	}
}

/**
* 分页显示
* @param {Object} pageindex
*/
function GetDataList(){
	var commentsType=$(".comment-type li.current").attr('data-type');
	$.ajax({
		type:"post",
		url:"APP_MAIN/Goods/getGoodsComments",
		data:{'comments_type' : commentsType, "goods_id" : $("#goods_id").val() },
		dataType:'json',
		success:function(data){
			var listhtml='';
			if(data['data'].length==0){
				$('.comment-con').html('<div class="tip-box"><i class="tip-icon"></i><div class="tip-text">还没有任何评价哦</div></div>');
				$('#pagination').hide();
				return false;
			}
			for(var i=0;i<data['data'].length;i++){
				var dataitem=data['data'][i];
				var member_name=dataitem['member_name'];
				member_name=dataitem['is_anonymous']==1?member_name.replace(member_name.substring(1,member_name.length),'***')+'(匿名)':member_name;
				listhtml+=' <div class="tablelist" style="border-bottom: 1px solid #e5e5e5;margin-bottom: 10px;">'
					+'<div class="user_info" style="margin-right:10px;">'
					+'<div class="face"><img src="__TEMP__/{$style}/public/images/default_user_portrait_0.png" style="width:35px;border-radius: 50%;"/></div>'
					+'<div class="name-box">'+member_name+'</div>'
					+'</div>'
					+'<dl>'
					+'<dd>'+dataitem['content']+'</dd>'
				if(dataitem['image']!=''){
					var imgs_arr=dataitem['image'].split(',');
					listhtml+='<dd style="margin:5px 0;">'
					for(var key in imgs_arr){
						listhtml+='<img src="__UPLOAD__/'+imgs_arr[key]+'" alt=""/>';	
					}
					listhtml+='</dd>';
					listhtml+='<dd class="photo-viewer"></dd>'
				}	
				listhtml+='<div class="date"><span>'+dataitem['addtime']+'</span> <span></span></div>';
				listhtml+='</dl>';
				if(dataitem['again_content']!=''){
					
					listhtml+='<div style="margin-left:-1px;float:right;margin-top: 9px;width:75%;">追加评价：</div>'
					+'<dl>'
					+'<div style="width: 26%;margin-right: 10px;height:auto;float: left;"></div>'
					+'<dd>'+dataitem['again_content']+'</dd>'
					if(dataitem['again_image']!=''){
						var imgs_arr=dataitem['again_image'].split(',');
						listhtml+='<dd>'
						for(var key in imgs_arr){
							listhtml+='<img src="__UPLOAD__/'+imgs_arr[key]+'" alt="" />';
						}
						listhtml+='</dd>';
					}
					listhtml+='<div class="date"><span>'+dataitem['again_addtime']+'</span> <span></span></div>';
					listhtml+='</dl>';
				}
				listhtml+='</div>';
			}
			$(".comment-con").html(listhtml);
		}
	});
}
</script>